package com.ldn.basic.dispose.vo;

/**
 * @author 李大牛家的牛 (scafel@163.com) 
 * @createDate 2024/7/9 - 16:32
 * @description 统一的数据返回格式 返回结果数据集
 **/
public class ResultDataVo<T> {

    // 结果状态码
    private int status;
    // 结果描述
    private String message;
    // 结果数据集
    private T data;
    // 返回时间戳
    private long timestamp;

    public ResultDataVo() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> ResultDataVo<T> success(T data) {
        ResultDataVo<T> resultData = new ResultDataVo<>();
        resultData.setStatus(200);
        resultData.setMessage("操作成功");
        resultData.setData(data);
        return resultData;
    }

    public static <T> ResultDataVo<T> fail(int code, String message) {
        ResultDataVo<T> resultData = new ResultDataVo<>();
        resultData.setStatus(code);
        resultData.setMessage(message);
        return resultData;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
}
